// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   check_delete_ok.java

package fund.pay;

import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;
import validata.ValidataTag;

public class check_delete_ok extends HttpServlet
{

	ServletContext application;
	HttpSession session;
	nseer_db_backup1 erp_db;

	public check_delete_ok()
	{
		erp_db = null;
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			java.io.PrintWriter out = response.getWriter();
			nseer_db_backup1 fund_db = new nseer_db_backup1(dbApplication);
			nseer_db_backup1 fund_db1 = new nseer_db_backup1(dbApplication);
			ValidataTag vt = new ValidataTag();
			if (fund_db.conn((String)dbSession.getAttribute("unit_db_name")) && fund_db1.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String config_id = request.getParameter("config_id");
				String fund_ID = request.getParameter("fund_ID");
				String choice = request.getParameter("choice");
				String check_time = request.getParameter("check_time");
				String checker = request.getParameter("checker");
				String checker_ID = request.getParameter("checker_ID");
				String pay_time = request.getParameter("pay_time");
				if (choice != null)
				{
					String sql6 = (new StringBuilder("select id from fund_workflow where object_ID='")).append(fund_ID).append("' and pay_time='").append(pay_time).append("' and ((check_tag='0' and config_id<'").append(config_id).append("') or (check_tag='1' and config_id='").append(config_id).append("'))").toString();
					ResultSet rs6 = fund_db.executeQuery(sql6);
					if (!rs6.next())
					{
						String sql8 = (new StringBuilder("select id from fund_executing where fund_ID='")).append(fund_ID).append("' and check_tag='0' and pay_time='").append(pay_time).append("'").toString();
						ResultSet rs8 = fund_db.executeQuery(sql8);
						if (rs8.next())
						{
							try
							{
								if (choice.equals(""))
								{
									String sql2 = (new StringBuilder("update fund_fund set check_tag='9' where fund_ID='")).append(fund_ID).append("'").toString();
									fund_db.executeUpdate(sql2);
									sql2 = (new StringBuilder("delete from fund_workflow where object_ID='")).append(fund_ID).append("' and pay_time='").append(pay_time).append("'").toString();
									fund_db.executeUpdate(sql2);
								} else
								{
									sql6 = (new StringBuilder("select id from fund_workflow where object_ID='")).append(fund_ID).append("' and config_id<'").append(config_id).append("' and config_id>='").append(choice).append("' and pay_time='").append(pay_time).append("'").toString();
									String sql;
									for (rs6 = fund_db.executeQuery(sql6); rs6.next(); fund_db1.executeUpdate(sql))
										sql = (new StringBuilder("update fund_workflow set check_tag='0' where id='")).append(rs6.getString("id")).append("'").toString();

								}
							}
							catch (Exception ex)
							{
								ex.printStackTrace();
							}
							response.sendRedirect("fund/pay/check_delete_ok.jsp?finished_tag=0");
						} else
						{
							response.sendRedirect("fund/pay/check_delete_ok.jsp?finished_tag=3");
						}
					} else
					{
						response.sendRedirect("fund/pay/check_delete_ok.jsp?finished_tag=2");
					}
				} else
				{
					response.sendRedirect("fund/pay/check_delete_ok.jsp?finished_tag=1");
				}
				fund_db.commit();
				fund_db1.commit();
				fund_db.close();
				fund_db1.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
